home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 May / EnigmA AMIGA RUN 18 (1997)(G.R. Edizioni)(IT)[!][issue 1997-05][EAR-CD II].iso / softwareupdate / system / amigados / amigadoslibrary / write.c < prev    next >
C/C++ Source or Header  |  1996-10-10  |  923b  |  41 lines

  1. /* Write.c   V1.0   93-03-15                        */
  2. /* ROM library: "dos.library/Write", (All versions) */
  3. /* Copyright 1993, Anders Bjerin, Amiga C Club      */
  4.  
  5. #include <dos/dos.h>
  6.  
  7. #include <clib/dos_protos.h>
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10.  
  11. UBYTE *version = "$VER: Write 1.0";
  12.  
  13. int main( int argc, char *argv[] );
  14. int main( int argc, char *argv[] )
  15. {
  16.   BPTR my_file;
  17.   int my_data[ 5 ] = { 1248, 2637, 842, 3721, 12 };
  18.   long bytes_written;
  19.  
  20.  
  21.   /* Open a new file: */
  22.   my_file = Open( "RAM:Score.dat", MODE_NEWFILE );
  23.   if( !my_file )
  24.     exit( 20 );
  25.  
  26.   /* Write some data to the file: */
  27.   bytes_written = Write( my_file, my_data, sizeof( my_data ) );
  28.  
  29.   /* Did we write all data? */ 
  30.   if( bytes_written != sizeof( my_data ) )
  31.     printf( "Error! Could not save all values!\n" );
  32.   else
  33.     printf( "All values were saved successfully!\n" );
  34.  
  35.   /* Close the file: */
  36.   Close( my_file );
  37.  
  38.   exit( 0 );
  39. }
  40.  
  41.